package com.epam.kozich.Service;

import org.springframework.transaction.annotation.Transactional;

import com.epam.kozich.dao.BookDAO;
import com.epam.kozich.dao.OrderDAO;
import com.epam.kozich.dao.PersonDAO;
import com.epam.kozich.model.*;

public class ServiceImpl implements Service {

	BookDAO bookDAO;
	PersonDAO personDAO;
	OrderDAO orderDAO;

	@Transactional
	public void addNewPerson(Person person) {
		personDAO.addPerson(person);

	}
	@Transactional
	public void changeBook(Book book) {
		bookDAO.updateBook(book);

	}
	@Transactional
	public void deleteBook(Book book) {
		bookDAO.deleteBook(book);

	}
	@Transactional
	public void deletePerson(Person person) {
		personDAO.deletePerson(person);

	}
	@Transactional
	public void printBannedPerson() {
		personDAO.outputBannedPerson();

	}
	@Transactional
	public void printBook() {
		bookDAO.getAllBooks();

	}
	@Transactional
	public void printOrderforPerson(Long id) {
		

	}
	@Transactional
	public void printPerson() {
		personDAO.outputPerson();

	}
	@Transactional
	public void saveNewBook(Book book) {
		bookDAO.addBook(book);
	}
	@Transactional
	public void bannedPerson(Person person) {
		person.setBanned(true);
		personDAO.updatePerson(person);

	}
	@Transactional
	public void addNewOrder(Order order) {
		orderDAO.save(order);

	}
}
